﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile.Samples.Location;

namespace GpSpotMe
{
    public partial class GpsSatellitePanel : UserControl
    {
        private GpsPosition p;

        public GpsSatellitePanel()
        {
            InitializeComponent();
        }

        public GpsPosition Datasource
        {
            get { return p; }
            set { p = value; }
        }
        public void DataBind()
        {
            if (p == null) return;
            if (p.SatellitesInSolutionValid &&
                                    p.SatellitesInViewValid)
            {
                dsSatellites.Satellites.Clear();
                foreach (Satellite sat in p.SatellitesInView)
                {
                    dsSatellites.Satellites.AddSatellitesRow(sat.Id, sat.Azimuth, sat.Elevation, sat.SignalStrength,
                    Array.IndexOf(p.SatellitesInSolution, sat) > -1);
                }
            }
        }
    }
}
